package com.gr



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
 */
@TestFor(ProjectService)
@Mock([Project, Division, Company])
class ProjectServiceTests {

	/**
	 * getlistAll()
	 */
	void testgetlistAll() {

		def company = new Company(title:"DU Organization", email:"duorgmain@duorg.com", startDate: new Date("2001/1/18"))
		def divA = new Division(title:"DivisionA", email:"divisiona@duorg.com", startDate:new Date("2011/3/21"), companyTo: company)

		new Project(title:"Project A1", email:"projectA1@duorg.com", startDate:new Date("8/18/2012"), divisionTo:null).save(validate: false)
		new Project(title:"Project A2", email:"projectA2@duorg.com", startDate:new Date("2011/2/12"), divisionTo:null).save(validate: false)

		def model = new ProjectService().getlistAll()

		assert model.size() == 2
		assert model[0].text == "Project A1"
		assert model[0].id == "Project A1"
		assert model[1].text == "Project A2"
		assert model[1].id == "Project A2"
	}
}

